package slicex

import (
	"errors"
)

func Delete[T any](src []T, index int) ([]T, T, error) {
	l := len(src)
	if index < 0 || l <= index {
		var zero T
		return nil, zero, errors.New("下标超出范围")
	}
	res := src[index]
	for i := index; i < l-1; i++ {
		src[i] = src[i+1]
	}
	src = src[:l-1]
	return src, res, nil
}
